using APP.HELPER.Data.Helper;
using System;
using System.Data;
using System.Data.SqlClient;
namespace Extra.ERP
{
	public class DATA
	{
		private string m_Database;
		private string m_Version;
		private DateTime m_Created;
		private string m_Path;
		public string Database
		{
			get
			{
				return this.m_Database;
			}
			set
			{
				this.m_Database = value;
			}
		}
		public string Version
		{
			get
			{
				return this.m_Version;
			}
			set
			{
				this.m_Version = value;
			}
		}
		public DateTime Created
		{
			get
			{
				return this.m_Created;
			}
			set
			{
				this.m_Created = value;
			}
		}
		public string Path
		{
			get
			{
				return this.m_Path;
			}
			set
			{
				this.m_Path = value;
			}
		}
		public string ProductName
		{
			get
			{
				return "Class DATA";
			}
		}
		public string ProductVersion
		{
			get
			{
				return "1.0.0.0";
			}
		}
		public DATA()
		{
			this.m_Database = "";
			this.m_Version = "";
			this.m_Created = DateTime.Now;
			this.m_Path = "";
		}
		public DATA(string Database, string Version, DateTime Created, string Path)
		{
			this.m_Database = Database;
			this.m_Version = Version;
			this.m_Created = Created;
			this.m_Path = Path;
		}
		public string NewID()
		{
			return SqlHelper.GenCode("DATA", "DATAID", "");
		}
		public bool Exist(string Database)
		{
			bool result = false;
			string[] myParams = new string[]
			{
				"@Database"
			};
			object[] myValues = new object[]
			{
				Database
			};
			SqlHelper sqlHelper = new SqlHelper();
			SqlDataReader sqlDataReader = sqlHelper.ExecuteReader("DATA_Get", myParams, myValues);
			if (sqlDataReader != null)
			{
				result = sqlDataReader.HasRows;
				sqlDataReader.Close();
				sqlHelper.Close();
			}
			return result;
		}
		public string Get(string Database)
		{
			string result = "";
			string[] myParams = new string[]
			{
				"@Database"
			};
			object[] myValues = new object[]
			{
				Database
			};
			SqlHelper sqlHelper = new SqlHelper();
			SqlDataReader sqlDataReader = sqlHelper.ExecuteReader("DATA_Get", myParams, myValues);
			if (sqlDataReader != null)
			{
				while (sqlDataReader.Read())
				{
					this.m_Database = Convert.ToString(sqlDataReader["Database"]);
					this.m_Version = Convert.ToString(sqlDataReader["Version"]);
					this.m_Created = Convert.ToDateTime(sqlDataReader["Created"]);
					this.m_Path = Convert.ToString(sqlDataReader["Path"]);
					result = "OK";
				}
				sqlDataReader.Close();
				sqlHelper.Close();
			}
			return result;
		}
		public string Get(SqlConnection myConnection, string Database)
		{
			string result = "";
			string[] myParams = new string[]
			{
				"@Database"
			};
			object[] myValues = new object[]
			{
				Database
			};
			SqlHelper sqlHelper = new SqlHelper();
			SqlDataReader sqlDataReader = sqlHelper.ExecuteReader(myConnection, "DATA_Get", myParams, myValues);
			if (sqlDataReader != null)
			{
				while (sqlDataReader.Read())
				{
					this.m_Database = Convert.ToString(sqlDataReader["Database"]);
					this.m_Version = Convert.ToString(sqlDataReader["Version"]);
					this.m_Created = Convert.ToDateTime(sqlDataReader["Created"]);
					this.m_Path = Convert.ToString(sqlDataReader["Path"]);
					result = "OK";
				}
				sqlDataReader.Close();
				sqlHelper.Close();
			}
			return result;
		}
		public string Get(SqlTransaction myTransaction, string Database)
		{
			string result = "";
			string[] myParams = new string[]
			{
				"@Database"
			};
			object[] myValues = new object[]
			{
				Database
			};
			SqlHelper sqlHelper = new SqlHelper();
			SqlDataReader sqlDataReader = sqlHelper.ExecuteReader(myTransaction, "DATA_Get", myParams, myValues);
			if (sqlDataReader != null)
			{
				while (sqlDataReader.Read())
				{
					this.m_Database = Convert.ToString(sqlDataReader["Database"]);
					this.m_Version = Convert.ToString(sqlDataReader["Version"]);
					this.m_Created = Convert.ToDateTime(sqlDataReader["Created"]);
					this.m_Path = Convert.ToString(sqlDataReader["Path"]);
					result = "OK";
				}
				sqlDataReader.Close();
				sqlHelper.Close();
			}
			return result;
		}
		public string Insert()
		{
			string[] myParams = new string[]
			{
				"@Database",
				"@Version",
				"@Created",
				"@Path"
			};
			object[] myValues = new object[]
			{
				this.m_Database,
				this.m_Version,
				this.m_Created,
				this.m_Path
			};
			SqlHelper sqlHelper = new SqlHelper();
			return sqlHelper.ExecuteNonQuery("DATA_Insert", myParams, myValues);
		}
		public string Insert(SqlTransaction myTransaction)
		{
			string[] myParams = new string[]
			{
				"@Database",
				"@Version",
				"@Created",
				"@Path"
			};
			object[] myValues = new object[]
			{
				this.m_Database,
				this.m_Version,
				this.m_Created,
				this.m_Path
			};
			SqlHelper sqlHelper = new SqlHelper();
			return sqlHelper.ExecuteNonQuery(myTransaction, "DATA_Insert", myParams, myValues);
		}
		public string Insert(string Database, string Version, DateTime Created, string Path)
		{
			string[] myParams = new string[]
			{
				"@Database",
				"@Version",
				"@Created",
				"@Path"
			};
			object[] myValues = new object[]
			{
				Database,
				Version,
				Created,
				Path
			};
			SqlHelper sqlHelper = new SqlHelper();
			return sqlHelper.ExecuteNonQuery("DATA_Insert", myParams, myValues);
		}
		public string Insert(SqlConnection myConnection, string Database, string Version, DateTime Created, string Path)
		{
			string[] myParams = new string[]
			{
				"@Database",
				"@Version",
				"@Created",
				"@Path"
			};
			object[] myValues = new object[]
			{
				Database,
				Version,
				Created,
				Path
			};
			SqlHelper sqlHelper = new SqlHelper();
			return sqlHelper.ExecuteNonQuery(myConnection, "DATA_Insert", myParams, myValues);
		}
		public string Insert(SqlTransaction myTransaction, string Database, string Version, DateTime Created, string Path)
		{
			string[] myParams = new string[]
			{
				"@Database",
				"@Version",
				"@Created",
				"@Path"
			};
			object[] myValues = new object[]
			{
				Database,
				Version,
				Created,
				Path
			};
			SqlHelper sqlHelper = new SqlHelper();
			return sqlHelper.ExecuteNonQuery(myTransaction, "DATA_Insert", myParams, myValues);
		}
		public string Update()
		{
			string[] myParams = new string[]
			{
				"@Database",
				"@Version",
				"@Created",
				"@Path"
			};
			object[] myValues = new object[]
			{
				this.m_Database,
				this.m_Version,
				this.m_Created,
				this.m_Path
			};
			SqlHelper sqlHelper = new SqlHelper();
			return sqlHelper.ExecuteNonQuery("DATA_Update", myParams, myValues);
		}
		public string Update(SqlTransaction myTransaction)
		{
			string[] myParams = new string[]
			{
				"@Database",
				"@Version",
				"@Created",
				"@Path"
			};
			object[] myValues = new object[]
			{
				this.m_Database,
				this.m_Version,
				this.m_Created,
				this.m_Path
			};
			SqlHelper sqlHelper = new SqlHelper();
			return sqlHelper.ExecuteNonQuery(myTransaction, "DATA_Update", myParams, myValues);
		}
		public string Update(string Database, string Version, DateTime Created, string Path)
		{
			string[] myParams = new string[]
			{
				"@Database",
				"@Version",
				"@Created",
				"@Path"
			};
			object[] myValues = new object[]
			{
				Database,
				Version,
				Created,
				Path
			};
			SqlHelper sqlHelper = new SqlHelper();
			return sqlHelper.ExecuteNonQuery("DATA_Update", myParams, myValues);
		}
		public string Update(SqlConnection myConnection, string Database, string Version, DateTime Created, string Path)
		{
			string[] myParams = new string[]
			{
				"@Database",
				"@Version",
				"@Created",
				"@Path"
			};
			object[] myValues = new object[]
			{
				Database,
				Version,
				Created,
				Path
			};
			SqlHelper sqlHelper = new SqlHelper();
			return sqlHelper.ExecuteNonQuery(myConnection, "DATA_Update", myParams, myValues);
		}
		public string Update(SqlTransaction myTransaction, string Database, string Version, DateTime Created, string Path)
		{
			string[] myParams = new string[]
			{
				"@Database",
				"@Version",
				"@Created",
				"@Path"
			};
			object[] myValues = new object[]
			{
				Database,
				Version,
				Created,
				Path
			};
			SqlHelper sqlHelper = new SqlHelper();
			return sqlHelper.ExecuteNonQuery(myTransaction, "DATA_Update", myParams, myValues);
		}
		public string Delete()
		{
			string[] myParams = new string[]
			{
				"@Database"
			};
			object[] myValues = new object[]
			{
				this.m_Database
			};
			SqlHelper sqlHelper = new SqlHelper();
			return sqlHelper.ExecuteNonQuery("DATA_Delete", myParams, myValues);
		}
		public string Delete(string Database)
		{
			string[] myParams = new string[]
			{
				"@Database"
			};
			object[] myValues = new object[]
			{
				Database
			};
			SqlHelper sqlHelper = new SqlHelper();
			return sqlHelper.ExecuteNonQuery("DATA_Delete", myParams, myValues);
		}
		public string Delete(SqlConnection myConnection, string Database)
		{
			string[] myParams = new string[]
			{
				"@Database"
			};
			object[] myValues = new object[]
			{
				Database
			};
			SqlHelper sqlHelper = new SqlHelper();
			return sqlHelper.ExecuteNonQuery(myConnection, "DATA_Delete", myParams, myValues);
		}
		public string Delete(SqlTransaction myTransaction, string Database)
		{
			string[] myParams = new string[]
			{
				"@Database"
			};
			object[] myValues = new object[]
			{
				Database
			};
			SqlHelper sqlHelper = new SqlHelper();
			return sqlHelper.ExecuteNonQuery(myTransaction, "DATA_Delete", myParams, myValues);
		}
		public DataTable GetList()
		{
			SqlHelper sqlHelper = new SqlHelper();
			return sqlHelper.ExecuteDataTable("DATA_GetList");
		}
	}
}
